import LogFactory from "@/log/LogFactory.ts";
import ProTree from "@/common/tree/ProTree.tsx";
import {SecurityUser} from "@/type/SecurityUser";
import {useLocation} from "react-router-dom";
import {MyTreeDataNode} from "@/common/tree";
import {Space} from "antd";

const log = LogFactory.getLogger("UserAuthComponent.UserAuthRole");
/**
 * 数据的节点类型扩展类型
 */
type Extend = {
    /**
     * 用户角色说明
     */
    explain: string,
}
const UserAuthRole = () => {
    const user = useLocation().state as SecurityUser;
    log.debug("用户角色管理组件加载", user);
    const titleRender = (node: MyTreeDataNode<Extend>) => {
        return <Space
            style={{
                height: "25px",
                fontSize: "16px",
                borderBottomColor: "blue"
            }}
            size={0}>
            <div style={{minWidth: "130px",}}> {node.title as string}</div>
            <span>{node.explain}</span>
        </Space>;
    }

    return (
        <>
            <ProTree<Extend>
                id={user.id}
                titleRender={titleRender}
                treeRenderUrl={"/manager/admin/user-role/authority-tree/" + user.id}
                checkStrictly={true}
                expandAll
            />
        </>
    );
};

export default UserAuthRole;